#ifndef HASHER
#define HASHER

#include <stdlib.h>

// used by OpGrupyBy and OpBEGroupBy

const int MOD = 1000000009;
const int BASE = 100000007;



class RowHasher {	// przemyslec i poprawic
  private:
  	int n;
  public:
  	RowHasher(int n_=0) : n(n_) {};
    size_t operator()(char* v) const {
    	uint32_t ret = 0;
    	v += sizeof(size_t) ;		// pomijamy hasha'a
    	int32_t* q = (int32_t*) v;
    	for(int i=0; i<n; i++) {
    		ret = (BASE*ret + q[i])%MOD;
    	}
    	return (size_t) ret;
    }
};

class IdHasher {
  public:
    size_t operator()(char* v) const {
    	return *((size_t*) v);
    }
};

//TODO zawsze zaklda sizeof(bool) = sizeof(int)
class RowEqual {
  private:
  	int n;
  public:
  	RowEqual(int n_) : n(n_) {};
    bool operator()(char* a, char* b) const {
    	a += sizeof(size_t);		// pomijamy hash'a
    	b += sizeof(size_t);		// pomijamy hash'a
    	int32_t* q = (int32_t*) a;
    	int32_t* w = (int32_t*) b;
    	for(int i=0; i<n; i++)
    		if(q[i] != w[i]) return false;
    	return true;
    }
};

#endif
